console.log("-----------------collection.js loaded---------------");

//import libs
import Vue from 'vue'
import Vuex from 'vuex'

//use vuex
Vue.use(Vuex)

let state = {
  colList: []
}

//window.localStorage.clear("goodsCollections");
var getItem = window.localStorage.getItem("goodsCollections");
if(getItem != null) {
  state.colList = getItem;
}

const mutations = {
  goodsCollection (context, arr) {
    var newArr = context.colList.push(arr);
    window.localStorage.setItem("goodsCollections", JSON.stringify(newArr));
    console.log(window.localStorage.getItem("goodsCollections"));
  }
}

//output
export default new Vuex.Store({
  state,
  mutations
})